<template>
	<view>
		<view class="cu-modal" :class="{ show: showModal }">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">蓝牙设备</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl">
					初始化蓝牙成功
				</view>
			</view>
		</view>
		<view class="padding ">
			<view class="cu-capsule">
				<view class='cu-tag '>
					<view class="flex-sub circle">1</view>
				</view>
				<view class="cu-tag ">
					设备
				</view>
			</view>
			<view class="flex flex-wrap padding" style="background-color:#fbbd08; border-radius: 10px;">
				<view class="basis-xs">测量设备</view>
				<view class="basis-xl" style="background-color:#f4f4f4; border-radius: 5px;" @click="showModal = !showModal;handlePrivacy()">
					尚未选择设备</view>
			</view>
		</view>
		<view class="padding">
			<view class="cu-capsule">
				<view class='cu-tag '>
					<view class="flex-sub circle">2</view>
				</view>
				<view class="cu-tag ">
					定位系统
				</view>
			</view>
			<view class="flex flex-wrap padding" style="background-color:#fbbd08; border-radius: 10px;">
				<view class="basis-xs">当前系统</view>
				<view class="basis-xl" style="background-color:#f4f4f4; border-radius: 5px;">
					<picker @change="PickerChange" :value="index" :range="picker">
						<view class="picker">
							{{index>-1?picker[index]:'手机'}}
						</view>
					</picker>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showModal: false, // 定义一个变量来控制模态对话框的显示和隐藏
				index: -1,
				picker: ['手机', '终端内部', '外置RTK']

			};
		},
		methods: {
			hideModal() {
				this.showModal = false; // 当你点击关闭按钮时，清除showModal变量，使得对话框隐藏
			},
			showModal(){
				console.log("111")
			},
			// 初始化蓝牙模块
			handlePrivacy() {
				console.log("初始化蓝牙模块")
				uni.openBluetoothAdapter({
					success(res) {
						// 状态正常  
						console.log("success", res)
					},
					fail(res) {},
					complete(res) {
						console.log("初始化蓝牙模块-openBluetoothAdapter", res)
					},
				})
			},
			PickerChange(e) {
				this.index = e.detail.value
			},
		},
	};
</script>
<style>
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}

	.circle {
		width: 15px;
		height: 15px;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #fbbd08;
	}
</style>